#include <iostream>
#define SIZE 100

using namespace std;

int all[SIZE], n, i, j, k;

void read();

int main()
{
	read();
	
	for (i = 0; i < n; ++i)
		if ((all[i] % k) != 0)
			for (j = i; j < n; ++j)
				all[j] = all[j + 1];
			
	for (i = 0; i < n; ++i)
		cout << all[i] << " ";
	
	
	
	return 0;
}

void read()
{
	cout << "n = ";
	cin >> n;
	cout << "k = ";
	cin >> k;
	for (i = 0; i < n; ++i)
	{	cout << "all[" << i << "]= ";
		cin >> all[i];
	}
}